package com.bwie.controller;

import com.bwie.common.domain.Users;
import com.bwie.common.result.Result;
import com.bwie.service.UserService;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
@CrossOrigin
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/login/{tel}")
    public Result<Users> login(@PathVariable String tel){
        Users u = userService.login(tel);
        return Result.success(u);
    }


    @PostMapping("/add")
    public Result<Users> add(@RequestBody Users users){
        userService.add(users);
        return Result.success(users);
    }

}
